import {ComponentType} from 'vc';
import {useRequest} from 'vue-request';
import {
  getMonitorItem,
  getMonitorStation,
  getAbnormalFacilitiesFilter,
  getAbnormalFacilitiesPollutionFilter
} from "@/views/modules/enterprise/apis";
import {formatSubData} from "@/views/modules/enterprise/modules/pollution-monitoring/formatData";
import {submitIndustryFn} from "@/views/modules/esg/utils/filterConfig";

export function useScreen(companyId, type) {
  const PAGE_SIZE = 10;

  const queryData = reactive<any>({
    pageNum: 1,
    pageSize: PAGE_SIZE,
    sortRule: '',
    searchTxt: ''
  });

  // 许可证编号
  const {data: numberData} = useRequest(getAbnormalFacilitiesFilter, {
    defaultParams: [{id: companyId, type: type}]
  });
  // 污染因子
  const {data: pollutionData} = useRequest(getAbnormalFacilitiesPollutionFilter, {
    defaultParams: [{id: companyId}]
  });

  const screen = computed(() => {
    return [
      {
        title: '排污许可证编号',
        component: ComponentType.MULTIPLE,
        options: numberData.value || [],
        submitFn: (data) => {
          queryData.licenceNo = data;
        }
      },
      {
        title: '污染因子',
        component: ComponentType.MULTIPLE,
        options: pollutionData.value || [],
        submitFn: (data) => {
          queryData.pollutionFactors = data;
        }
      },
      {
        title: '超标起止日期',
        component: ComponentType.DATE,
        type: 'daterange',
        shortcuts: [30, 90, 180, 365, 365 * 3],
        submitFn: (data) => {
          queryData.startDate = data[0];
          queryData.endDate = data[1];
        }
      }
    ];
  });

  return {
    PAGE_SIZE,
    screen,
    queryData
  };
}
